![]() |
Random |
||||
Header: | Quickdraw.h | Carbon status: | Supported | |
Obtains a pseudorandom integer.
SInt16 Random ();
A pseudorandom integer, uniformly distributed in the range -32767 to 32767.
The value Random returns depends solely on the global variable randSeed, which the QuickDraw InitGraf function initializes to 1. Each time the Random function executes, it uses a numerical algorithm to change the value of randSeed to prevent it from returning the same value each time it is called.
To prevent your application from generating the same sequence of pseudo-random numbers each time it is executed, initialize the randSeed global variable, when your application starts up, to a volatile long word variable such as the current date and time. If you would like to generate the same sequence of pseudo-random numbers twice, on the other hand, simply set randSeed to the same value before calling Random for each sequence.
Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)